home *** CD-ROM | disk | FTP | other *** search
/ Super PC 34 / Super PC 34 (Shareware).iso / spc / UTIL / DJGPP2 / V2 / DJLSR200.ZIP / src / libc / ansi / stdio / rename.txh < prev    next >
Encoding:
Text File  |  1995-07-10  |  1.7 KB  |  44 lines

  1. @node rename, file system
  2. @subheading Syntax
  3.  
  4. @example
  5. #include <stdio.h>
  6.  
  7. int rename(const char *oldname, const char *newname);
  8. @end example
  9.  
  10. @subheading Description
  11.  
  12. This function renames an existing file or directory @var{oldname} to
  13. @var{newname}.  If @var{newname} exists, then it is first removed.  If
  14. @var{newname} is a directory, it must be empty (or else @var{errno} will
  15. be set to @code{ENOTEMPTY}), and must not include @var{oldname} in its
  16. path prefix (otherwise, @var{errno} will be set to @code{EINVAL}).  If
  17. @var{newname} exists, both @var{oldname} and @var{newname} must be of the
  18. same type (both directories or both regular files) (or else @var{errno}
  19. will be set to @code{ENOTDIR} or @code{EISDIR}), and must reside on the
  20. same logical device (otherwise, @var{errno} will be set to @code{EXDEV}). 
  21. Wildcards are not allowed in either @var{oldname} or @var{newname}.  DOS
  22. won't allow renaming a current directory even on a non-default drive (you
  23. will get the @code{EBUSY} or @code{EINVAL} in @var{errno}).
  24. @code{ENAMETOOLONG} will be returned for pathnames which are longer than
  25. the limit imposed by DOS.  If @var{oldname} doesn't exist, @var{errno}
  26. will be set to @code{ENOENT}.  For most of the other calamities, DOS will
  27. usually set @var{errno} to @code{EACCES}.
  28.  
  29. If anything goes wrong during the operation of @code{rename()}, the
  30. function tries very hard to leave the things as ther were before it was
  31. invoked, but it might not always succeed.
  32.  
  33. @subheading Return Value
  34.  
  35. Zero on success, nonzero on failure.
  36.  
  37. @subheading Example
  38.  
  39. @example
  40. rename("c:/mydir/some.doc", "c:/yourdir/some.sav");
  41. rename("c:/path1/mydir", "c:/path2");
  42. @end example
  43.  
  44.